#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int dp[101][40001];



struct item{
	int weight,value,num;
};

	

int main(){
	int t,m;
	scanf("%d%d",&m,&t);
	item a[m];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<m;i++)
		scanf("%d%d%d",&a[i].value,&a[i].weight,&a[i].num);
	for(int i=1;i<=m;i++)
		for(int j=1;j<=t;j++){
			int kmax=min(a[i-1].num,j/a[i-1].weight);
			for(int k=0;k<=kmax;k++)
				dp[i][j] = max(dp[i][j],dp[i-1][j-k*a[i-1].weight]+k*a[i-1].value);
		}	
	printf("%d",dp[m][t]);
	return 0;
}
